package com.itheima.duotai;

public class Test {
    public static void main(String[] args) {

        Sheep sheep = new Sheep();
        System.out.println(sheep.mao);
        sheep.eat();
        Wolf wolf = new Wolf();
        System.out.println(wolf.mao);
        wolf.eat();

        //多态的典型应用   父类引用指向子类对象
        //数据类型 变量名= 值;
        Sheep s= new Wolf();
        System.out.println(s.mao);//查看成员变量 看到的是父类的值
        s.eat();//运行成员方法 执行的是子类的逻辑  子类重写父类的方法
    }

}

class Sheep {
   String mao = "羊毛";

    public void eat() {
        System.out.println("羊吃草");
    }
}
// 披着羊皮的狼
class Wolf extends Sheep {
    String mao = "狼毫";

    @Override
    public void eat() {
        System.out.println("狼吃羊");
    }
}